<template>
	<view class="box">
		<view class="contentData" v-if="enterpriseStaffList.length>0">
			<view v-for="(item,index) in enterpriseStaffList" @click="toCard(item)">
				<image :src="item.avatar"></image>
				<view>
					<view class="left">
						<view>
							<text>{{item.nickname}}</text>
							<text>{{item.position_name}}</text>
						</view>
						<view>{{item.autograph}}</view>
					</view>
					<view class="right" @click.stop="operation(item,index)">
						<image :src=" item.client_check == 1 ? imgHost+'like.png' : imgHost+'noLike.png'"></image>
						<!-- <view>{{item.client_check == 1 ? '已加入' : '未加入'}}</view> -->
					</view>
				</view>
			</view>
		</view>
		<view class="noData" v-else>
			暂无信息
		</view>
	</view>
</template>

<script>
	import {
	     HTTP_REQUEST_URL
	} from '@/config/app.js';
	import {
		getEnterpriseStaffList,
		deleteCard
	} from "@/api/userminp.js"
	export default {
		data() {
			return {
				// 图片路径拼接
				imgHost:HTTP_REQUEST_URL + '/static/contactsCircle/',
				// 员工列表
				enterpriseStaffList:[],
				// 企业id
				qiyeId:null,
				// 企业名称
				qiyeName:"",
				// 页数
				page:1
			};
		},
		onLoad(option) {
			this.qiyeId=option.id
		},
		onShow() {
			this.enterpriseStaffList=[]
			this.getEnterpriseStaffList()
		},
		mounted() {
			
		},
		methods:{
			// 操作名片
			operation(item,index){
				uni.switchTab({
					url:"/pages/index/minp?share_uid="+item.uid
				})
				return true
				if(item.client_check==1){
					deleteCard({
						del_id:item.uid
					}).then(res=>{
						uni.showToast({
							title:res.message
						})
						this.enterpriseStaffList[index].client_check=0
						// this.enterpriseStaffList=[]
						// this.getEnterpriseStaffList()
					}).catch(err=>{
						uni.showToast({
							title:err
						})
					})
				}else{
					uni.navigateTo({
						url:"/pages/userminp/mine/tianjia/tianjia?share="+item.uid
					})
				}
			},
			// 跳转名片页面
			toCard(item){
				uni.switchTab({
					url:"/pages/index/minp?share_uid="+item.uid
					// url:"/pages/userminp/mine/minpmb/minpmb?uid="+item.uid
				})
			},
			// 名片列表
			getEnterpriseStaffList(){
				getEnterpriseStaffList(this.qiyeId,this.page).then(res=>{
					this.qiyeName =  res.data.enterprise.name
					for(var i=0;i<res.data.list.length;i++){
						this.enterpriseStaffList.push(res.data.list[i])
					}
				})
			}
		},
		// onReachBottom(){
		// 	this.page++;
		// 	this.getEnterpriseStaffList()
		// }
	}
</script>

<style>
	page {
		background-color: white;
	}
</style>

<style lang="scss" scoped>
	.box{
		padding: 20rpx;
		.contentData{
			// margin-top:20rpx;
			&>view{
				border: 2rpx solid #F0F0F0;
				border-radius: 20rpx;
				margin-bottom: 20rpx;
				display: flex;
				align-items: center;
				padding: 20rpx;
				&>image{
					border-radius: 10rpx;
					width: 110rpx;
					height: 110rpx;
				}
				&>view{
					width: 78%;
					margin-left: 20rpx;
					display: flex;
					align-items: center;
					justify-content: space-between;
					.left{
						&>view:nth-of-type(1){
							display: flex;
							align-items: center;
							margin-bottom: 20rpx;
							text{
								font-size: 34rpx;
								// font-weight: 600;
							}
							text:last-of-type{
								font-size: 24rpx;
								color: #999999;
								margin-left: 20rpx;
							}
							image{
								height: 42rpx;
								width: 40rpx;
								margin-right: 10rpx;
							}
						}
						&>view:nth-of-type(2){
							color: #999999;
							font-size: 28rpx;
						}
					}
					.right{
						text-align: center;
						image{
							width: 36rpx;
							height: 36rpx;
						}
					}
				}
			}
		}
		.noData{
			text-align: center;
			padding-top: 100rpx;
		}
	}
</style>
